// eslint-disable-next-line
import { UserLayout, GlobalLayout } from '@/layouts'

const RouteView = {
  name: 'RouteView',
  render: (h: any) => h('router-view')
}

export const asyncRouterMap = [

  {
    path: '/',
    name: 'index',
    component: GlobalLayout,
    meta: { title: '主页' },
    redirect: '/common/welcome',
    children: [
      // dashboard
      {
        path: '/member',
        name: 'member',
        redirect: '/member/list',
        component: RouteView,
        meta: { title: '农户档案', keepAlive: true, icon: 'form', permission: ['dashboard'] },
        children: [
          {
            path: '/member/list',
            name: 'member-list',
            component: () => import(/* webpackChunkName: "member" */ '@/views/member/list/index.vue'),
            meta: { title: '农户与家庭成员', keepAlive: false, permission: ['dashboard'] }
          },
          {
            path: '/member/farmers',
            name: 'member-farmers',
            component: () => import(/* webpackChunkName: "member" */ '@/views/member/farmers/index.vue'),
            meta: { title: '农户与家庭成员', keepAlive: false, permission: ['dashboard'] }
          },
          {
            path: '/member/grain',
            name: 'member',
            component: () => import(/* webpackChunkName: "member" */ '@/views/member/grain/index.vue'),
            meta: { title: '农民粮食种植信息', keepAlive: true, permission: ['dashboard'] }
          },
          {
            path: '/member/large',
            name: 'memberLarge',
            component: () => import(/* webpackChunkName: "member" */ '@/views/member/large/index.vue'),
            meta: { title: '种植大户', keepAlive: true, permission: ['dashboard'] }
          },
          {
            path: '/member/plant',
            name: 'member-plant',
            component: () => import(/* webpackChunkName: "member" */ '@/views/member/plant/index.vue'),
            meta: { title: '种粮一次补贴', keepAlive: false, permission: ['dashboard'] }
          },
          {
            path: '/member/large-grain',
            name: 'memberLargeGrain',
            component: () => import(/* webpackChunkName: "member" */ '@/views/member/farmers/index.vue'),
            meta: { title: '种粮大户补贴申报管理', keepAlive: true, permission: ['dashboard'] }
          },
          {
            path: '/member/workplace',
            name: 'Workplace',
            component: () => import(/* webpackChunkName: "member" */ '@/views/exception/404.vue'),
            meta: { title: '档案变动与查询', keepAlive: true, permission: ['dashboard'] }
          },
          {
            path: '/member/death',
            name: 'memberDeath',
            component: () => import(/* webpackChunkName: "member" */ '@/views/member/death/index.vue'),
            meta: { title: '死亡农户列表', keepAlive: true, permission: ['dashboard'] }
          }
        ]
      },

      // forms
      {
        path: '/subsidy',
        redirect: '/subsidy/roster',
        component: RouteView,
        meta: { title: '补贴信息', icon: 'form', permission: ['form'] },
        children: [
          {
            path: '/subsidy/info',
            name: 'subsidy/info',
            component: () => import(/* webpackChunkName: "subsidy" */ '@/views/subsidy/information/index.vue'),
            meta: { title: '项目信息', keepAlive: true, permission: ['form'] }
          },
          {
            path: '/subsidy/roster',
            name: '/subsidy/roster',
            component: () => import(/* webpackChunkName: "subsidy" */ '@/views/subsidy/roster/index.vue'),
            meta: { title: '资金分配', keepAlive: true, permission: ['form'] }
          },
          {
            path: '/subsidy/publish',
            name: 'subsidy/publish',
            component: () => import(/* webpackChunkName: "subsidy" */ '@/views//subsidy/publish/index.vue'),
            meta: { title: '信息公示', keepAlive: true, permission: ['form'] }
          },
          {
            path: '/form/advanced-form1',
            name: 'AdvanceForm',
            component: () => import(/* webpackChunkName: "subsidy" */ '@/views/exception/404.vue'),
            meta: { title: '补贴查询统计', keepAlive: true, permission: ['form'] }
          }
        ]
      },

      // list
      {
        path: '/fund-release',
        name: 'fund-release',
        component: RouteView,
        redirect: '/fund-release/list',
        meta: { title: '资金发放', icon: 'table', permission: ['table'] },
        children: [
          {
            path: '',
            name: 'TableListWrapper',
            hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
            component: () => import(/* webpackChunkName: "fund-release" */ '@/views/exception/404.vue'),
            meta: { title: '接收补贴的银行账户', keepAlive: true, permission: ['table'] }
          },
          {
            path: '/fund-release/list',
            name: 'fundReleaseList',
            component: () => import(/* webpackChunkName: "fund-release" */ '@/views/fund-release/list/index.vue'),
            meta: { title: '向银行提交的发放清单', keepAlive: true, permission: ['table'] }
          },
          {
            path: '/fund-release/record',
            name: 'fundReleaseRecord',
            component: () => import(/* webpackChunkName: "fund-release" */ '@/views/fund-release/record/index.vue'),
            meta: { title: '补贴资金发放批次记录', keepAlive: true, permission: ['table'] }
          },
          {
            path: '/fund-release/receipt',
            name: 'fundReleaseReceipt',
            component: () => import(/* webpackChunkName: "fund-release" */ '@/views/fund-release/receipt/index.vue'),
            meta: { title: '银行发放的补贴回单', keepAlive: true, permission: ['table'] },
          },
          {
            path: '/list/card1',
            name: 'CardList',
            component: () => import(/* webpackChunkName: "fund-release" */ '@/views/exception/404.vue'),
            meta: { title: '补贴发放往来查询', keepAlive: true, permission: ['table'] }
          }
        ]
      },

      // profile
      {
        path: '/profile',
        name: 'profile',
        component: RouteView,
        redirect: '/profile/basic',
        meta: { title: '补贴监督', icon: 'profile', permission: ['profile'] },
        children: [
          {
            path: '/profile/basic',
            name: 'ProfileBasic',
            component: () => import(/* webpackChunkName: "profile" */ '@/views/exception/404.vue'),
            meta: { title: '公众举报信息监管', permission: ['profile'] }
          },
          {
            path: '/profile/advanced',
            name: 'ProfileAdvanced',
            component: () => import(/* webpackChunkName: "profile" */ '@/views/exception/404.vue'),
            meta: { title: '内部事务监管', permission: ['profile'] }
          },
          {
            path: '/profile/advanced1',
            name: 'ProfileAdvanced',
            component: () => import(/* webpackChunkName: "profile" */ '@/views/exception/404.vue'),
            meta: { title: '银行划转监管', permission: ['profile'] }
          }
        ]
      },

      // result
      {
        path: '/statistics',
        name: 'statistics',
        component: RouteView,
        redirect: '/statistics/export',
        meta: { title: '查询统计', icon: 'check-circle-o', permission: ['result'] },
        children: [
          {
            path: '/statistics/export',
            name: 'statisticsExport',
            component: () => import(/* webpackChunkName: "statistics" */ '@/views//statistics/export/index.vue'),
            meta: { title: '业务数据导入、导出', keepAlive: false, hiddenHeaderContent: true, permission: ['result'] }
          },
          {
            path: '/statistics/echarts',
            name: '/statistics/echarts',
            component: () => import(/* webpackChunkName: "statistics" */ '@/views//statistics/echarts/index.vue'),
            meta: { title: '统计', keepAlive: false, hiddenHeaderContent: true, permission: ['result'] }
          }
        ]
      },

      // Exception
      {
        path: '/system',
        name: 'exception',
        component: RouteView,
        redirect: '/exception/403',
        meta: { title: '系统管理', icon: 'warning', permission: ['exception'] },
        children: [
          {
            path: '/system/admin',
            name: 'systemAdmin',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/user/list/index.vue'),
            meta: { title: '用户管理', permission: ['exception'] }
          },
          {
            path: '/system/power',
            name: 'systemPower',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/system/power/index.vue'),
            meta: { title: '菜单与权限管理', permission: ['exception'] }
          },
          {
            path: '/system/power-group',
            name: 'systemPowerGroup',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/system/power-group/index.vue'),
            meta: { title: '权限组管理', permission: ['exception'] }
          },
          {
            path: '/system/administrative-division',
            name: 'systemArea',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/system/administrative-division/index.vue'),
            meta: { title: '行政区划管理', permission: ['exception'] }
          },
          {
            path: '/system/projects',
            name: 'systemProjects',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/system/projects/index.vue'),
            meta: { title: '补贴项目管理', permission: ['exception'] }
          },
          {
            path: '/system/import-old-data',
            name: 'systemImportOldData',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/system/import-old-data/index.vue'),
            meta: { title: '旧版基础数据导入', permission: ['exception'] }
          },
          {
            path: '/system/monitor',
            name: 'systemMonitor',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/system/monitor/index.vue'),
            meta: { title: '系统数据监控', permission: ['exception'] }
          }
        ]
      },

      // account
      {
        path: '/help',
        component: RouteView,
        redirect: '/help/document',
        name: 'help',
        meta: { title: '帮助中心', icon: 'user', keepAlive: true, permission: ['user'] },
        children: [
          {
            path: '/help/QA',
            name: 'document1',
            component: () => import(/* webpackChunkName: "help" */ '@/views/help/QA/index.vue'),
            meta: { title: '帮助', keepAlive: true, permission: ['user'] }
          },
          {
            path: '/help/document',
            name: 'document',
            component: () => import(/* webpackChunkName: "help" */ '@/views/help/document/index.vue'),
            meta: { title: '帮助', keepAlive: true, permission: ['user'] }
          },
          {
            path: '/help/wx',
            name: 'wx',
            component: () => import(/* webpackChunkName: "help" */ '@/views/help/wx/index.vue'),
            meta: { title: '帮助', keepAlive: true, permission: ['user'] }
          },
          {
            path: '/help/download',
            name: 'wx',
            component: () => import(/* webpackChunkName: "help" */ '@/views/help/download/index.vue'),
            meta: { title: '下载中心', keepAlive: true, permission: ['user'] }
          },
        ]
      },
      {
        path: '/history-data',
        component: () => import(/* webpackChunkName: "help" */ '@/views/system/import-old-data/index.vue'),
        name: 'history-data',
        meta: { title: '历年数据', icon: 'user', keepAlive: true, permission: ['user'] }
      }
    ]
  },
  {
    path: '*', redirect: '/404', hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/common',
    component: GlobalLayout,
    meta: { title: '' },
    redirect: '/common/welcome',
    children: [
      {
        path: 'welcome',
        name: 'welcome',
        meta: {
          title: '欢迎页'
        },
        component: () => import(/* webpackChunkName: "user" */ '@/views/common/welcome.vue')
      },
      {
        path: 'settings',
        name: 'settings',
        component: () => import(/* webpackChunkName: "user" */ '@/views/account/settings/Index.vue'),
        meta: { title: '用户操作交流', hideHeader: true, permission: ['user'] },
        redirect: '/account/settings/base',
        hideChildrenInMenu: true,
        children: [
          {
            path: 'base',
            name: 'BaseSettings',
            component: () => import(/* webpackChunkName: "user" */ '@/views/account/settings/BaseSetting.vue'),
            meta: { title: '基础信息设置', hidden: true, permission: ['user'] }
          },
          {
            path: 'security',
            name: 'SecuritySettings',
            component: () => import(/* webpackChunkName: "user" */ '@/views/account/settings/Security.vue'),
            meta: { title: '修改密码', hidden: true, keepAlive: true, permission: ['user'] }
          }
        ]
      }
    ],
    hidden: true,
  },
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        meta: {
          title: '登录'
        },
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login.vue')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register.vue')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult.vue')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404.vue')
  }

]
